<template>
	<view>
		<scroll-view :scroll-y="modalName==null" class="page" :class="show">
			<cu-custom bgColor="bg-gradual-pink" :isBack="false">
				<block slot="content">类型列表</block>
			</cu-custom>
			<view v-for="(item,index) in subjects" :key="index" class="bg-grey padding margin text-center">
				<!-- <view >{{item.type_name}}</view> -->
				<button @click="navToPage(item.type_id)">{{item.type_name}}</button>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				subjects: []
			}
		},
		methods: {
			getSubject: function() {
				var that = this;
				that.http.sendRequest("/subjects", 'get', {}, {
					"Content-Type": "application/json;charset=UTF-8"
				}).then(function(res) {
					if (res.code == 0) {
						that.subjects = that.subjects.concat(JSON.parse(res.data));
					}
				})
			},
			navToPage: function(data) {
				console.log(data);
				uni.navigateTo({
					url: "../video/video?type_id=" + data
				})
			}
		},
		onLoad() {
			this.getSubject();
			console.log(this.subjects.length);

		}
	}
</script>

<style>

</style>
